<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<header>
	<!--  <div class="logo">
		<span>乙秒购</span>
	</div>-->
	<div class="title" style="float:left">
		<span style="color: #FFF">广搜天下商城管理系统</span>

	</div>
<!-- 	<div id="buttons"
		style="width:200px;height:100%;float:left;padding-top:25px"></div> -->
	<div
		style="width:500px;height:100%;float:right;text-align:center;line-height:80px">
		<!--<span style="color: #FFF">地址：</span><span id="address" style="color: #FFF"></span> &nbsp; &nbsp; &nbsp; --><span style="color: #FFF">管理员：</span><span
			id="principal" style="color: #FFF"></span>
	</div>
	<audio id="audios" src="audio/tishiyin.mp3"></audio>

</header>
<script type="text/javascript">
	var super_id = localStorage.getItem("directId")
	var super_name = localStorage.getItem("directname")
	var super_principal = localStorage.getItem("directprincipal")
	var super_address = localStorage.getItem("directaddress");
	document.getElementById("principal").innerText = super_principal
	//document.getElementById("address").innerText = super_address
	$(function() {
		setInterval(function() {
			$.post(urls + "orderFormAction/getOrderFormBySuper",
				{
					superId : localStorage.getItem("directId"),
					typeId : 3,
					pageNum : 1,
					pageCount : 100,
					status : 1
				},
				function(res) {
				console.log(res.orderlist.length)
					if (res.orderlist.length != 0) {
						$("#audios")[0].play();
					}
				})

		}, 60000)
	})




	$(function() {
	    getbutton()//获取按钮的样式
	})

	function getbutton() {
	    $("#buttons").empty();
		var superstatus = localStorage.getItem("superstatus");
		var button1 = "<button type='button' onclick='stopbusiness(1)' class='btn btn-primary'>暂停营业</button>";
		var button2 = "<button type='button' onclick='stopbusiness(0)' class='btn btn-success'>开始营业</button>";
		if (superstatus == 0) {
			$("#buttons").append(button1)
		} else if (superstatus == 1) {
			$("#buttons").append(button2)
		}
	}

	function stopbusiness(status) {//控制超市状态
		if (confirm("是否继续操作？")) {
				$.post(urls + "agentAction/freezeSuperMarket",
					{
						id : super_id,
						status : status
					},
					function(res) {
						if (res == true) {
						    if(status==1){
						       localStorage.setItem("superstatus","1")
						    }else  if(status==0){
						       localStorage.setItem("superstatus","0")
						    }
							getbutton()							
						} else if (res == false){
							alert("操作失败")
						}
					}
			)
		}
	}
</script>